<script>
import apis from "./apis/apis";
export default {
  onLaunch: async function () {
    console.log("App Launch");
    const code = await uni.login();
    if (code[0]) {
      console.warn("登录失败..");
      return;
    }
    const wxCode = code[1].code;
    this.$http.post(apis.getOpenId, { code: wxCode }).then((res) => {
      console.log("getOpenId.res:", res);
      this.$store.commit("setToken", res);
    });
  },
  onShow: function () {
    console.log("App Show");
  },
  onHide: function () {
    console.log("App Hide");
  },
};
</script>

<style lang="scss">
/*每个页面公共css */
@import "uview-ui/index.scss";

.mt20 {
  margin-top: 20rpx;
}
</style>
